﻿using System;
delegate int NumberChanger (int n);
namespace Main.Delegate {
    public class Delegate {
        static int num = 10;
        public static int AddNum (int p) {
            num += p;
            return num;
        }

        public static int MultNum (int q) {
            num *= q;
            return num;
        }
        public static int getNum () {
            return num;
        }
        public static void show () {
            // 创建委托实例
            NumberChanger nc;
            NumberChanger nc1 = new NumberChanger (AddNum);
            NumberChanger nc2 = new NumberChanger (MultNum);
            nc = nc1;
            nc += nc2;
            // 调用多播
            nc (5);
            Console.WriteLine ("Value of Num: {0}", getNum ());
        }
    }
}